package com.scarecrow.olga.entity {
	import com.scarecrow.olga.core.IUpdateable;
	import com.scarecrow.olga.error.VerboseError;
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author Santiago.J.Elizalde
	 */
	public class Entity implements IEntity {
		
		private var _id:String;
		private var _name:String;
		
		private var _creationTime:Number;
		private var destroyed:Boolean;
		
		public function Entity(name:String = "") {
			_id = EntityRegistry.getUID();
			EntityRegistry.registerEntity(this);
			name = name == "" ? "ent_" + _id : name;
			_creationTime = getTimer();
		}
		
		/* INTERFACE com.scarecrow.olga.entity.IEntity */
		
		public final function get id():String {
			return _id;
		}
		
		public final function get name():String {
			return _name;
		}
		
		public final function get creationTime():uint {
			return _creationTime;
		}
		
		/**
		 * Releases this entity from the game. The entity is destroyed in the 
		 * process and removed from all registries.
		 */
		public function release():void {
			destroyed = true;
			EntityRegistry.releaseEntity(this);
		}
	}
}